package ga.crossover;

import java.util.Random;

import ga.model.Chromosome;

public class Single implements Crossover {
	Random rand = new Random();

	@Override
	public Chromosome[] crossover(Chromosome[] parents) {
		double rate= rand.nextDouble()*100
		if(rate>crossoverRate)
		{
			int index = rand.nextInt(200);
			Chromosome ch1, ch2;
			ch1 = new Chromosome(parents[0].getChromosome().substring(0, index)
					+ parents[1].getChromosome().substring(index + 1));
			ch2 = new Chromosome(parents[1].getChromosome().substring(0, index)
					+ parents[0].getChromosome().substring(index + 1));
	
			Chromosome[] child = { ch1, ch2 };
			return child;
		}
		else 
			return parents;
	}

}
